package com.tutorialspoint.autowire;

import com.tutorialspoint.base.MyBase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp extends MyBase {
	public static void main(String[] args) {
		// autowire byName
		ApplicationContext context_byName = 
	            new ClassPathXmlApplicationContext("Beans_byName.xml");
		TextEditor te = (TextEditor) context_byName.getBean("textEditor");
		te.spellCheck();
		// te.getName();
		
		// autowire byType
		ApplicationContext context_byType = 
	            new ClassPathXmlApplicationContext("Beans_byType.xml");
		TextEditor te1 = (TextEditor) context_byType.getBean("textEditor");
		te1.spellCheck();
		// te1.getName();
		
		// autowire by constructor
		ApplicationContext context_byCtor = 
	            new ClassPathXmlApplicationContext("Beans_byCtor.xml");
		TextEditor te2 = (TextEditor) context_byCtor.getBean("textEditor");
		te2.spellCheck();
		// te2.getName();
				
		// close context
		MainApp.closeContext(context_byName);
		MainApp.closeContext(context_byType);
		MainApp.closeContext(context_byCtor);
	}
}
